package com.yb.guigu.pick.security.bean;

import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/5/31 15:07
 * FileName: GuiguAbstractAutuenticationToken
 * Description:
 */

public class GuiguUsernamePasswordAuthenticationToken extends GuiguAbstractAuthenticationToken {
    /**
     * Creates a token with the supplied array of authorities.
     *
     * @param authorities the collection of <tt>GrantedAuthority</tt>s for the principal
     * represented by this authentication object.
     */
    private String username;

    private String password;


    public GuiguUsernamePasswordAuthenticationToken(GuiguPickUser guiguPickUser) {
        super(guiguPickUser);
        this.username=guiguPickUser.getUsername();
        this.password=guiguPickUser.getPassword();
    }


    public GuiguUsernamePasswordAuthenticationToken(GuiguPickUser guiguPickUser, Collection<? extends GrantedAuthority> authorities) {
        super(guiguPickUser,authorities);
        this.username=guiguPickUser.getUsername();
        this.password=guiguPickUser.getPassword();
    }


    public static GuiguUsernamePasswordAuthenticationToken authenticated(GuiguPickUser guiguPickUser,Collection<? extends GrantedAuthority> authorities){

        return new GuiguUsernamePasswordAuthenticationToken(guiguPickUser,authorities);
    }

    public static GuiguUsernamePasswordAuthenticationToken unAuthenticated(GuiguPickUser guiguPickUser){
        return new GuiguUsernamePasswordAuthenticationToken(guiguPickUser);
    }


    public String getUsername() {
        return username;
    }

    public String getPassword() {
        return password;
    }
}

